import { _decorator, Component, log, Node } from 'cc';
import RecycleScroll from './RecycleScroll';
import { ScrollItem } from './ScrollItem';
import CCCExtend from '../Script/Utils/CCCExtend';
const { ccclass, property } = _decorator;

@ccclass('Scene')
export class Scene extends Component {
    @property(RecycleScroll)
    itemScroll: RecycleScroll = null;

    onLoad() {
        CCCExtend.init();
        this.itemScroll.onItemRender = this.onItemRender.bind(this);
        this.itemScroll.onItemClicked = this.onItemClicked.bind(this);
    }

    protected start(): void {
        this.itemScroll.numItems = 10000;
    }

    onItemRender(index: number, node: Node) {
        node.getComponent(ScrollItem).setData(index);
    }

    onItemClicked(index: number, node: Node) {
        log(`click: ${index}`)
    }
}

